package com.srzk.youthleagueback.controller;

import com.srzk.youthleagueback.pojo.Lecture;
import com.srzk.youthleagueback.pojo.Meeting;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.LectureService;
import com.srzk.youthleagueback.service.MeetingService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/part2")
public class LectureController {
    @Autowired
    LectureService service;

    @GetMapping("/lectureList")
    public Result<List<Lecture>> getLectureList(@RequestParam("user")String user, @RequestParam("year")String year){
        return service.getLectureList(user,year);
    }

    @GetMapping("/lecture")
    public Result<Lecture> getLecture(@RequestParam("user")String user, @RequestParam("year")String year,@RequestParam("id")int id){
        return service.getLecture(user,year,id);
    }

    @PostMapping("/lecture")
    public Result<Map<String,Long>> addLecture(Lecture lecture){
        return service.addLecture(lecture);
    }

    @DeleteMapping("/lecture")
    public Result<String> deleteLecture(@RequestParam("user")String user, @RequestParam("year")String year,@RequestParam("id")int id){
        return service.deleteLecture(user, year, id);
    }

    @PostMapping("/lectureUpdate")
    public Result<String> updateLecture(Lecture lecture){
        return service.updateLecture(lecture);
    }
}
